/*   _________  __  ____________  ___   ___  ____
 *  / ___/ __ \/  |/  /_  __/ _ \/ _ | / _ \/ __/
 * / /__/ /_/ / /|_/ / / / / , _/ __ |/ // / _/  
 * \___/\____/_/  /_/ /_/ /_/|_/_/ |_/____/___/  
 * COMTRADE file parser
 * -------------------------------------------------------------------------
 * Copyright (C) 2013 - Ericson Norberto A Santos (ericsonnorberto@gmail.com)
 * Federal University Of Campina Grande - UFCG
 * 
 * Supports on IEEE Std C37.111-1999 COMTRADE-99 and IEEE Std C37.111-1991
 * COMTRADE-91 standards.
 * 
 * ABSTRACT:
 * A common format for data files and exchange medium used for the interchange
 * of various types of fault, test, or simulation data for electrical power
 * systems is defined. Sources of transient data are described, and the case of
 * diskettes as an exchange medium is recommended.
 * Issues of sampling rates, filters, and sample rate conversions for transient
 * data being exchanged are discussed. Files for data exchange are specified,
 * as is the organization of the data. A sample file is given.
 * 
 * License information:
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 * 
*/
#ifndef COMTRADE_STRUCTURES_HPP
    #define COMTRADE_STRUCTURES_HPP

#include "COMTRADE_defines.hpp"

struct COMTRADE_FILE_LIST
{
    bool   file_exist;
    string file_type;
    string file_name;
};
typedef COMTRADE_FILE_LIST comtrade_file_list;

/* COMTRADE configuration file details */
struct COMTRADE_CFG_GENERAL_INFORMATION
{
    string station_name;
    string rec_dev_id;
    string rev_year;
};
typedef COMTRADE_CFG_GENERAL_INFORMATION config_general_information;

/* COMTRADE configuration channel information */
struct COMTRADE_CFG_CHANNEL_INFORMATION
{
    int    ch_tt;
    int    ch_ta;
    int    ch_td;
};
typedef COMTRADE_CFG_CHANNEL_INFORMATION config_channel_information;

/* COMTRADE configuration configuration analog channel information */
struct COMTRADE_CFG_ANALOG_CHANNEL_INFORMATION
{
    int    ch_Ac;
    string ch_id;
    string ch_phase;
    string ch_ccbm;
    string ch_units;
    double ch_a;
    double ch_b;
    double ch_skew;
    int    ch_min;
    int    ch_max;
    double ch_pri_v;
    double ch_sec_v;
    string ch_PS;
};
typedef COMTRADE_CFG_ANALOG_CHANNEL_INFORMATION config_analog_channel_information;

/* COMTRADE configuration configuration digital channel information */
struct COMTRADE_CFG_DIGITAL_CHANNEL_INFORMATION
{
    int    ch_Dn;
    string ch_id;
    string ch_phase;
    string ch_ccbm;
    int    ch_nstate;
};
typedef COMTRADE_CFG_DIGITAL_CHANNEL_INFORMATION config_digital_channel_information;

/* COMTRADE configuration configuration line frequency */
struct COMTRADE_CFG_LINE_FREQUENCY
{
    double line_frequency;
};
typedef COMTRADE_CFG_LINE_FREQUENCY config_line_frequency;

/* COMTRADE configuration sampling rate information */
struct COMTRADE_CFG_SAMPLING_RATE_INFORMATION
{
    int    nrates;
    double samp;
    int    endsamp;
};
typedef COMTRADE_CFG_SAMPLING_RATE_INFORMATION config_sampling_rate_information;

/* COMTRADE configuration date time stamps */
struct COMTRADE_CFG_DATE_TIME_STAMPS
{
    int    dt_dd;
    int    dt_mm;
    int    dt_yy;
    int    hr_hh;
    int    hr_mm;
    double hr_ss;
    int    trig_dt_dd;
    int    trig_dt_mm;
    int    trig_dt_yy;
    int    trig_hr_hh;
    int    trig_hr_mm;
    double trig_hr_ss;
};
typedef COMTRADE_CFG_DATE_TIME_STAMPS config_date_time_stamps;

/* COMTRADE configuration data file type */
struct COMTRADE_CFG_DATA_FILE_FORMAT
{
    string file_type;
};
typedef COMTRADE_CFG_DATA_FILE_FORMAT config_data_file_format;

/* COMTRADE configuration time stamp multiplier */
struct COMTRADE_CFG_TIME_STAMP_MULTIPLIER
{
    double timemult_factor;
};
typedef COMTRADE_CFG_TIME_STAMP_MULTIPLIER config_time_stamp_multiplier;

/* General configuration structure */
struct CFG_FILE
{
    config_general_information general_information;
    config_channel_information channel_information;
    vector<config_analog_channel_information> analog_channel_information;
    vector<config_digital_channel_information> digital_channel_information;
    config_line_frequency line_frequency;
    config_sampling_rate_information sampling_rate_information;
    config_date_time_stamps date_time_stamps;
    config_data_file_format data_file_type;
    config_time_stamp_multiplier time_stamp_multiplier;
};
typedef CFG_FILE cfg_data_file;




/*  */
struct COMTRADE_DAT_ANALOG_CHANNELS
{
    int    ak;
    double ak_d;
};
typedef COMTRADE_DAT_ANALOG_CHANNELS data_analog_channels;

struct COMTRADE_DAT_DIGITAL_CHANNELS
{
    int    dm;
    double dm_d;
};
typedef COMTRADE_DAT_DIGITAL_CHANNELS data_digital_channels;

struct DAT_FILE
{
    int    n;
    int    timestamp;
    vector<data_analog_channels>  analog_channels;
    vector<data_digital_channels> digital_channels;
};
typedef DAT_FILE dat_data_file;



#endif
/* COMTRADE_STRUCTURES_HPP */